//
//  HOMNSDictionaryTests.m
//  HigherOrderMessaging
//
//  Created by Ofri Wolfus on 11/10/06.
//  Copyright 2006 Ofri Wolfus. All rights reserved.
//

#import "HOMNSDictionaryTests.h"


@implementation HOMNSDictionaryTests

- (id)init {
	if ((self = [super init])) {
		unsigned i;
		
		smallDict = [[NSDictionary alloc] initWithObjectsAndKeys:@"a", [NSNumber numberWithUnsignedInt:1U],
			@"b", [NSNumber numberWithUnsignedInt:2U], @"abc", [NSNumber numberWithUnsignedInt:3U], nil];
		largeDict = [[NSMutableDictionary alloc] initWithCapacity:10000U];
		largeDictResult = [[NSMutableDictionary alloc] init];
		
		for (i = 0; i < 10000; i++)
			[(NSMutableDictionary *)largeDict setObject:[NSString stringWithFormat:@"%d", i] forKey:[NSNumber numberWithUnsignedInt:i]];
	}
	
	return self;
}

- (void)dealloc {
	[smallDict release]; smallDict = nil;
	[largeDict release]; largeDict = nil;
	[largeDictResult release]; largeDictResult = nil;
	[super dealloc];
}

- (BOOL)verifyResult:(NSDictionary *)dict ofTest:(SEL)sel {
	NSString *name = NSStringFromSelector(sel);
	
	if ([name hasPrefix:@"testLargeDictionary"]) {
		DPTestAssert([dict isEqualToDictionary:largeDictResult], @"The resulting dictionary doesn't match the expected result. Result = %@", dict);
	}
	
	return [super verifyResult:dict ofTest:sel];
}

@end
